Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add radioactive chunk miche and make AI to use and omit radioactive chunks #5867

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Patryk26g
Copy link
Contributor

@Patryk26g Patryk26g commented Jan 31, 2025

Brief Description of What This PR Does

  • Adds radioactive chunk miche. The miche fills only after the nucleus is developed just as expected.
  • AI omits the radioactive chunks when it starts taking damage
  • AI with melanosomes stays near the chunk to produce ATP

Here's the link to the test save where there are some species that have melanosomes: https://dev.revolutionarygamesstudio.com/files/Public/Testing%20Resources/Saves/Radioactive%20Chunk%20AI%20Test%20Save.thrivesave

Related Issues

Closes #5857
Closes #5855
Closes #5856

Progress Checklist

Note: before starting this checklist the PR should be marked as non-draft.

  • PR author has checked that this PR works as intended and doesn't
    break existing features:
    https://wiki.revolutionarygamesstudio.com/wiki/Testing_Checklist
    (this is important as to not waste the time of Thrive team
    members reviewing this PR)
  • Initial code review passed (this and further items should not be checked by the PR author)
  • Functionality is confirmed working by another person (see above checklist link)
  • Final code review is passed and code conforms to the
    styleguide.

Before merging all CI jobs should finish on this PR without errors, if
there are automatically detected style issues they should be fixed by
the PR author. Merging must follow our
styleguide.

@Patryk26g Patryk26g added this to the Release 0.8.1 milestone Jan 31, 2025
@CountingBeeps
Copy link
Contributor

Didn't test, but the code all checks out Auto-Evo wise

@Patryk26g Patryk26g changed the title Add radioactive chunk miche Add radioactive chunk miche and make AI omit radioactive chunks Feb 1, 2025
@Patryk26g Patryk26g changed the title Add radioactive chunk miche and make AI omit radioactive chunks Add radioactive chunk miche and make AI to use and omit radioactive chunks Feb 1, 2025
@@ -497,6 +510,16 @@ private void ChooseActions(in Entity entity, ref MicrobeAI ai, ref CompoundAbsor
// There is no reason to be engulfing at this stage
control.SetStateColonyAware(entity, MicrobeState.Normal);

// If the microbe has radiation protection it means it has melanosomes and can stay near tha radioactive chunks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment

return false;
}

var oppositeDirection = position.Position + (position.Position - chosenChunk.Value.Position);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be normalized and then multiplied by a certain distance? I think that this math may end up picking a point really near if the distance between the chunk and the current position gets too low.

}

// If the microbe is close to the chunk it doesn't need to go any closer
if (position.Position.DistanceSquaredTo(chosenChunk.Value.Position) < 700.0f)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a slight bit of randomness in the distance could be used here to make cells not always stop at an exact distance away from a chunk? (the microbe AI should already have access to a random instance that is fetched for each entity)

return;

foreach (ref readonly var chunk in chunksSet.GetEntities())
lock (terrainChunkDataCache)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this second level of locking is unnecessary and could be replaced with a comment like:

// As the chunk lock is always held when building all of the chunk caches, the other individual cache objects don't need separate locks to protect them

Copy link
Member

@hhyyrylainen hhyyrylainen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is already in very good shape but I had a few small technical comments on the code (I haven't playtested).

{
// Ignore already despawning chunks
ref var timed = ref chunk.Get<TimedLife>();
if (chunk.Has<TimedLife>())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new code? Is this really that useful to add here? This means that relatively the chunk cache will take quite a bit longer to build. And my hunch is that this doesn't help much as it takes just a few seconds for chunks to dissolve, so microbes don't see that many disappearing chunks even without this check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In progress
3 participants